#include <iostream>
#include <fstream>
#include <string>
#include "bundle.h"

int main(int argc, char *argv[])
{
    if (argc < 3)
    {
        std::cout<<"argv[1]解压文件名称：\n";
        std::cout<<"argv[2]解压后文件名\n";
        return -1;
    }

    std::string ifilename=argv[1];//解压文件名
    std::string ofilename=argv[2];

    std::ifstream ifs;
    ifs.open(ifilename,std::ios::binary);
    ifs.seekg(0,std::ios::end);
    size_t f_size=ifs.tellg();
    ifs.seekg(0,std::ios::beg);
    std::string body;
    body.resize(f_size);
    ifs.read(&body[0],f_size);
    ifs.close();

    std::string unpacked=bundle::unpack(body);

    std::ofstream ofs;
    ofs.open(ofilename,std::ios::binary);
    ofs.write(&unpacked[0],unpacked.size());
    ofs.close();
    return 0;
}